package main

import "fmt"

func main() {
	s3 := []int{}
	fmt.Println("s3 = ", s3)

	// append函数追加元素
	s3 = append(s3)
	s3 = append(s3, 1)
	s3 = append(s3, 2, 3)
	fmt.Println("s3 = ", s3)

	s4 := []int{1, 2, 4, 5}

	i2 := s4[2:]
	fmt.Println("i2 = ", i2)

	i3 := append([]int{3}, i2...)
	fmt.Println("i3 = ", i3)

	ints := append([]int{3}, s4[2:]...)
	fmt.Println("ints = ", ints)

	i4 := append([]int{3}, s4[2:]...)
	fmt.Println("i4 = ", i4)

	i5 := append(s4[:2], 3)
	fmt.Println("i5 = ", i5)
	fmt.Println("s4= ", s4)

	s4 = append(s4[:2], append([]int{3}, s4[2:]...)...)
	fmt.Println("s4 = ", s4)

	src1 := []int{1, 2, 3}
	dst1 := make([]int, 4, 5)

	src2 := []int{1, 2, 3, 4, 5}
	dst2 := make([]int, 3, 3)

	fmt.Println("before copy, src1 = ", src1)
	fmt.Println("before copy, dst1 = ", dst1)

	fmt.Println("before copy, src2 = ", src2)
	fmt.Println("before copy, dst2 = ", dst2)

	copy(dst1, src1)
	copy(dst2, src2)

	fmt.Println("after copy, src1 = ", src1)
	fmt.Println("after copy, dst1 = ", dst1)

	fmt.Println("after copy, src2 = ", src2)
	fmt.Println("after copy, dst2 = ", dst2)

}
